#include "TestReport.h"
#include "delay.h"
#include "serPort3.h"
#include "stm32f4xx_hal.h"
#include "unity.h"
#include <stdint.h>

extern UART_HandleTypeDef huart3;

static uint16_t totalTests  = 0;
static uint16_t passedTests = 0;
static uint16_t failedTests = 0;

void WriteTestReport(const char* testName) {
  ++totalTests;

  if(!Unity.CurrentTestFailed) {
    ++passedTests;
    //("TEST,%s,PASS\n", testName);
  } else {
    ++failedTests;
    //ser3_send_log("TEST,%s,FAIL\n", testName);
  }
  delay_ms(200);
}

void PrintTestSummary(void) {
  //ser3_send_log("\n=== UNITY TEST SUMMARY ===\n");
  delay_ms(200);
  //ser3_send_log("Total : %d\n", totalTests);
  delay_ms(200);
  //ser3_send_log("Passed: %d\n", totalTests - Unity.TestFailures);
  delay_ms(200);
  //ser3_send_log("Failed: %d\n", Unity.TestFailures);
  delay_ms(200);
  //ser3_send_log("===========================\n\n");
  delay_ms(200);
}
void unity_output_char(int ch) {
  if(ch == '\n') {
    char crlf[] = "\r\n";
    HAL_UART_Transmit(&huart3, (uint8_t*) crlf, 2, HAL_MAX_DELAY);
  } else {
    HAL_UART_Transmit(&huart3, (uint8_t*) &ch, 1, HAL_MAX_DELAY);
  }
}
